#include<iostream>
#include<vector>

using namespace std;

class Solution {
public:
    vector<int> productExceptSelf(vector<int>& nums) {
        int n = nums.size();
        vector<int> dp(n), g(n);
        dp[0] = g[n - 1] = 1;
        for (int i = 1; i < n; i++)
        {
            dp[i] = dp[i - 1] * nums[i - 1];
        }

        for (int i = n - 2; i >= 0; i--)
        {
            g[i] = g[i + 1] * nums[i + 1];
        }

        vector<int>ret(n);
        for (int i = 0; i < n; i++)
        {
            ret[i] = dp[i] * g[i];
        }

        return ret;
    }
};

int main()
{
    return 0;
}